<%--

<!------------------------------------------------------------------------------
 - Copyright 2006 CORE Solutions Limited
 - All rights reserved.
 - PROPRIETARY AND CONFIDENTIAL INFORMATION.
 - Use is subject to license terms.
 -
 - FUNCTION ID      :   CODE
 - AUTHOR           :   Saint Peng 
 - DATE CREATE      :   2006/01/05
 - DESCRIPTION      :   a CHILD TAB JSP file for the function, CODE
 -                  :   
 -                  :   
 -                  :   
 -
 - MODIFICATION HISTORY:
 - DATE         AUTHOR          VERSION NO.         COMMENT
 - -----------  --------------  ------------------  -------------------
 - 2006/01/05   Saint Peng      1.0                 source is generated.
 -
 -
 -
------------------------------------------------------------------------------->

--%>
<%@ include file="/jsp/com/erp/app/common/jsp/directives_include.jsp"%>

<%@ page import="com.erp.app.setup.codeSetup.vo.CodeDtlVo"%>
<%@ page import="com.erp.app.setup.codeSetup.web.CodeMaintenanceAction"%>
<%@ page import="com.erp.app.setup.codeSetup.web.CodeMaintenanceForm"%>
<%@ page import="com.erp.app.setup.codeSetup.web.CodeDtlRow"%>

<%@ include file="/jsp/com/erp/app/common/jsp/html_include.jsp"%>

<jsp:useBean id="codeMaintenanceForm" scope="session" type="com.erp.app.setup.codeSetup.web.CodeMaintenanceForm" />

<%
ArrayList codeDtlList = codeMaintenanceForm.getMultiRows(CodeMaintenanceAction.TAB_IDX_DTL);
pageContext.setAttribute("codeDtlList", codeDtlList);
%>

<chtml:button form="codeMaintenanceForm" pageEvent="<%=CodeMaintenanceAction.ACTION_ADD_DTL%>" styleClass="button1"/>

<!-- MUST use the following example to mark fields as mandatory field inputs-->
<!--
<td class="grid_header" nowrap><span class="mandatory_label">
<bean:message key="label.general.mandatory.field"/>
...</span></td>
-->
<%
rowReadOnly = false;
TableSchema[] childTsArray = codeMaintenanceForm.getChildTs();
TableSchema childTs = childTsArray[CodeMaintenanceAction.TAB_IDX_DTL];
%>
<table class="table_top">
<tr>
	<td class="grid_page" align="left">
	<%if (codeMaintenanceForm.getTotalPage() == 0 ) {%>
		&nbsp;
	<%} else {%>
		<input type="button" value="Go" class="button1" onClick="javascript:doSubmit('<%=codeMaintenanceForm.ACTION_SCROLL_TO%>');" >
		Page
		<html:text property="scrollTo" styleClass="textbox1" readonly="<%=rowReadOnly%>" maxlength="4" size="4" value="<%=String.valueOf(codeMaintenanceForm.getCurrentPage())%>"/>
		of <%=codeMaintenanceForm.getTotalPage()%>
	<%}%>
		<input type="button" value="|&lt;&lt;" class="button1" onClick="javascript:doSubmit('<%=codeMaintenanceForm.ACTION_SCROLL_TO_FIRST_PAGE%>');" <%=codeMaintenanceForm.getSidx() == 0 ? "disabled" : ""%>>
		<input type="button" value="&lt;&lt;" class="button1" onClick="javascript:doSubmit('<%=codeMaintenanceForm.ACTION_SCROLL_LEFT%>');" <%=codeMaintenanceForm.getSidx() == 0 ? "disabled" : ""%>>
		<input type="button" value="&gt;&gt;" class="button1" onClick="javascript:doSubmit('<%=codeMaintenanceForm.ACTION_SCROLL_RIGHT%>');" <%=codeMaintenanceForm.getSidx() < Integer.parseInt(codeMaintenanceForm.getLastPageSidx()) ? "" : "disabled"%>>
		<input type="button" value="&gt;&gt|" class="button1" onClick="javascript:doSubmit('<%=codeMaintenanceForm.ACTION_SCROLL_TO_LAST_PAGE%>');" <%=codeMaintenanceForm.getSidx() < Integer.parseInt(codeMaintenanceForm.getLastPageSidx()) ? "" : "disabled"%>>
	</td>
</tr>
<table/>
	
<table class="table_grid">

	<tr class="grid_header">
		<td class="grid_header_col" nowrap>
			<html:text useExtensions="true" uiType="label" name="codeMaintenanceForm" childTsIndex="current" property="refCode"/>
		</td>
		<td class="grid_header_col" nowrap>
			<html:text useExtensions="true" uiType="label" name="codeMaintenanceForm" childTsIndex="current" property="dtlRefDesc"/>
		</td>
		<td class="grid_header_col" nowrap>
			<html:text useExtensions="true" uiType="label" name="codeMaintenanceForm" childTsIndex="current" property="dtlRefStatus"/>
		</td>
		<td class="grid_header_col" nowrap>
			<html:text useExtensions="true" uiType="label" name="codeMaintenanceForm" childTsIndex="current" property="dtlRef1"/>
		</td>
		<td class="grid_header_col" nowrap>
			<html:text useExtensions="true" uiType="label" name="codeMaintenanceForm" childTsIndex="current" property="dtlRef2"/>
		</td>
		<td class="grid_header_col" nowrap>
			<html:text useExtensions="true" uiType="label" name="codeMaintenanceForm" childTsIndex="current" property="dtlRef3"/>
		</td>
		<td class="grid_header_col" nowrap>
            <html:text useExtensions="true" uiType="label" name="codeMaintenanceForm" childTsIndex="current" property="dtlSeq"/>
		</td>
	</tr>

	<logic:iterate id="codeDtlRow" name="codeDtlList" indexId="idx" length="<%=String.valueOf(ProjectConstants.MAX_DISPLAY)%>" offset="<%=String.valueOf(codeMaintenanceForm.getSidx())%>">

	<%
		CodeDtlRow row = (CodeDtlRow) codeDtlRow;
		boolean isDelete = CommonUtil.isEmpty(row.getIsDelete());
	%>

	<% if(row != null ) {%>

	<tr <%=(idx.intValue()%2 == 0)? "class='grid_result1'": "class='grid_result2'"%>>
		<td nowrap>
		    <% if (row.getRowMode().equals(ProjectConstants.ROW_MODE_CREATE)) { %>
			<%
			colSize = String.valueOf(childTs.getColSizeByObjectId("LBL_DTL_REF_CODE"));
			displaySize = String.valueOf(childTs.getDisplaySizeByObjectId("LBL_DTL_REF_CODE"));
			%>
			<html:text property="refCode" styleClass="textbox1" readonly="<%=!isDelete%>" size="<%=colSize%>" maxlength="<%=displaySize%>" value="<%=CommonUtil.nullToString(row.getRefCode())%>"/>
			<%} else {%>
              <bean:write name="codeDtlRow" property="refCode" filter="true"/>
			  <html:hidden property="refCode" value="<%=CommonUtil.nullToString(row.getRefCode())%>"/>
			<%}%>
		</td>
		<td nowrap>
			<%
			textAreaCols = String.valueOf(childTs.getTextAreaColSizeByObjectId("LBL_DTL_REF_DESC"));
			textAreaRows = String.valueOf(childTs.getTextAreaRowSizeByObjectId("LBL_DTL_REF_DESC"));
			%>
			<html:textarea property="dtlRefDesc" styleClass="textarea1" readonly="<%=!isDelete%>" rows="<%=textAreaRows%>" cols="<%=textAreaCols%>" value="<%=CommonUtil.nullToString(row.getDtlRefDesc())%>"/>
			<input type="button" name="..." value="..." class="button1" 
			<%if (isDelete) {%>
			onclick="<%="doSubmit('" + CodeMaintenanceAction.ACTION_EDIT_DESC + "', '"+ String.valueOf(idx) +"')"%>"
			 <%}%>>
		</td>
		<td nowrap>
			<select name="dtlRefStatus" <%=formReadOnly ? "disabled=\"true\"" : ""%> class="selectBox1">
			    <%where = " TYPE = '" +  ProjectConstants.CONSTANT_TYPE_ACT_INACT + "' ";%>
				<option value="">
				<chtml:options table="T_SYS_CONSTANTS"
				valuecolumn="CONSTANT_CODE"
				textcolumn="CONSTANT_NAME"
				where= "<%=where%>"
				order="CONSTANT_NAME"
				selected="<%=row.getDtlRefStatus()%>"
				 />
		        </select>
		</td>
		<td nowrap>
			<%
			colSize = String.valueOf(childTs.getColSizeByObjectId("LBL_DTL_REF_1"));
			displaySize = String.valueOf(childTs.getDisplaySizeByObjectId("LBL_DTL_REF_1"));
			%>
			<html:text property="dtlRef1" styleClass="textbox1" readonly="<%=!isDelete%>" size="<%=colSize%>" maxlength="<%=displaySize%>" value="<%=CommonUtil.nullToString(row.getDtlRef1())%>"/>
		</td>
		<td nowrap>
			<%
			colSize = String.valueOf(childTs.getColSizeByObjectId("LBL_DTL_REF_2"));
			displaySize = String.valueOf(childTs.getDisplaySizeByObjectId("LBL_DTL_REF_2"));
			%>
			<html:text property="dtlRef2" styleClass="textbox1" readonly="<%=!isDelete%>" size="<%=colSize%>" maxlength="<%=displaySize%>" value="<%=CommonUtil.nullToString(row.getDtlRef2())%>"/>
		</td>
		<td nowrap>
			<%
			colSize = String.valueOf(childTs.getColSizeByObjectId("LBL_DTL_REF_3"));
			displaySize = String.valueOf(childTs.getDisplaySizeByObjectId("LBL_DTL_REF_3"));
			%>
			<html:text property="dtlRef3" styleClass="textbox1" readonly="<%=!isDelete%>" size="<%=colSize%>" maxlength="<%=displaySize%>" value="<%=CommonUtil.nullToString(row.getDtlRef3())%>"/>
		</td>
		<td nowrap>
			<html:text useExtensions="true" uiType="text" name="codeDtlRow" property="dtlSeq" readonly="<%=rowReadOnly%>" />
		</td>
	</tr>

	<%} else { %>

		<html:hidden property="isDelete" value="<%=row.getIdx()%>"/>

		<!--MUST INCLUDE hidden fields for all input objects such as textbox, textarea, check box, radio button, select box, etc.-->
		<html:hidden property="dtlRefDesc" value="<%=CommonUtil.nullToString(row.getDtlRefDesc())%>"/>
		<html:hidden property="dtlRefStatus" value="<%=CommonUtil.nullToString(row.getDtlRefStatus())%>"/>
		<html:hidden property="dtlRef1" value="<%=CommonUtil.nullToString(row.getDtlRef1())%>"/>
		<html:hidden property="dtlRef2" value="<%=CommonUtil.nullToString(row.getDtlRef2())%>"/>
		<html:hidden property="dtlRef3" value="<%=CommonUtil.nullToString(row.getDtlRef3())%>"/>
		<html:hidden property="refCode" value="<%=CommonUtil.nullToString(row.getRefCode())%>"/>

	<%} %>

		<html:hidden property="idx" value="<%=row.getIdx()%>" />
		<html:hidden property="rowMode"  value="<%=row.getRowMode()%>"/>

	</logic:iterate>

</table>

